package models;

import java.util.List;

public class User {
	private int id;
	private String userName;
	private String password;
	private List<Role> roles;
	private int personId;
	
	public User(){
		
	}
	
	public User(int id, String userName, String password) {
		this.id = id;
		this.userName = userName;
		this.password = password;
	}
	
	public int getId() {
		return this.id;
	}
	
	public void setId(int id) {
		this.id = id;
	}
	
	public String getUserName(){
		return this.userName;
	}
	
	public void setUserName(String username) {
		this.userName = username;
	}
	
	public String getPassword(){
		return this.password;
	}
	
	public void setPassword(String password){
		this.password = password;
	}
	
	public List<Role> getRoles(){
		return this.roles;
	}
	
	public void setRoles(List<Role> roles){
		this.roles = roles;
	}

	public int getPersonId() {
		return personId;
	}

	public void setPersonId(int personId) {
		this.personId = personId;
	}
	
	public boolean getIsAdmin(){
		return getIsUserInRole("Admin");
	}
	
	public boolean getIsStudent(){
		return getIsUserInRole("Student");
	}
	
	public boolean getIsTutor(){
		return getIsUserInRole("Tutor");
	}
	
	public boolean getIsLecturer(){
		return getIsUserInRole("Lecturer");
	}
	
	public boolean getIsUserInRole(String roleName) {
		for(Role r : roles){
			if(r.getName().equals(roleName))
				return true;
		}
		return false;
	}
}
